home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9605 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: newshost.cyberramp.net!news
  2. From: sinan@cyberramp.net (John Noland)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: A question on for loop..
  5. Date: 12 Mar 1996 01:26:13 GMT
  6. Organization: Prose Software
  7. Distribution: world
  8. Message-ID: <4i2jrl$ect@newshost.cyberramp.net>
  9. References: <4hn80a$98q@male.EBay.Sun.COM>
  10. NNTP-Posting-Host: ramp1-12.cyberramp.net
  11. X-Newsreader: WinVN 0.99.5
  12.  
  13. In article <4hn80a$98q@male.EBay.Sun.COM>, murali@sooraj.ebay.sun.com says...
  14.  
  15. >In the following piece of code:
  16. >
  17. >for(i=0;i< 20; i++)
  18. >{
  19. >  if(condition==FALSE)
  20. >  continue;
  21. >} 
  22. >
  23. >Let us assume i=10 before it entered the loop.
  24.  
  25. I don't understand what this means. How does it matter what the value
  26. of i was *before* it entered the loop? The for loop is the only one I
  27. see in your example and it initializes i to zero.
  28.  
  29. >The condition was false. So the continue statement
  30. >got executed.
  31. >
  32. >Will control now go to the third statement in the for loop?
  33. >i.e. will i be incremented by 1 and again tested for the condition?
  34.  
  35. In any loop construct, continue is basically the same as having a goto
  36. to a label located just before the end-brace for that block.
  37. for (i=0;i < 20;i++) {
  38. ...
  39. ...
  40. goto contin; /* same as continue */
  41. ...
  42. ...
  43. contin: ;
  44. }
  45.  
  46. So, it would end up doing what you say above.
  47.  
  48. This is straight out of K&R1. (Someone stole my K&R2, and I'm pissed!!)
  49.  
  50. -John
  51.  
  52.